package com.zmx.common.common.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 大小写转换
 * @ClassName: TransformUpperOrLowerUtil
 * @Author zhaomxr
 * @Date 2021-11-16 14:34
 */
public class TransformUpperOrLowerUtil {

    /**
     * 将map key值转换为大写
     * @param orgMap
     * @return
     */
    public static Map<String, Object> transformUpperCase(Map<String, Object> orgMap) {
        if (orgMap == null || orgMap.isEmpty()) {
            return orgMap;
        }
        Map<String, Object> resultMap = new HashMap<String, Object>(orgMap.size());
        Set<String> keySet = orgMap.keySet();
        for (String key : keySet) {
            String newKey = key.toUpperCase();
            resultMap.put(newKey, orgMap.get(key));
        }
        return resultMap;
    }

    /**
     * 将map key值转换为小写
     * @param orgMap
     * @return
     */
    public static Map<String, Object> transformLowerCase(Map<String, Object> orgMap) {
        if (orgMap == null || orgMap.isEmpty()) {
            return orgMap;
        }
        Map<String, Object> resultMap = new HashMap<String, Object>(orgMap.size());
        Set<String> keySet = orgMap.keySet();
        for (String key : keySet) {
            String newKey = key.toLowerCase();
            resultMap.put(newKey, orgMap.get(key));
        }
        return resultMap;
    }
}
